//左侧、预览区、右侧编辑区对象
//左侧组件区对象
var leftComsZone = {
    initTag: 1,
    tagInfo: {}, //material tags info eg:page
    imagesInfo: {page: 0, hasMore: true}, //我的图库信息page
    userMaterialsInfo: {page: 0, hasMore: true}, //我的素材
    getMaterials: function (option) {
        //option:page tag drake more
        this.initTag = $(".com-name-ul > li").first().data("tag");
        var page = option.page || 1, tag = option.tag || this.initTag, drake = option.drake || {};
        var secId = "#com-box-" + tag;
        option.comSection = $("#com-box-" + tag);
        option.page = page;
        option.tag = tag;
        if (option.comSection.length === 0) {
            this.tagInfo[option.tag] = {page: option.page, more: true};
            this.requestMaterials(option);
        } else {
            //get next page and show more
            if (option.more === true) {
                option.page = this.tagInfo[option.tag].page + 1;
                this.tagInfo[option.tag].page = option.page;
                option.comSection.find(".com-get-more").show();
                this.requestMaterials(option);
                option.comSection.find(".com-get-more").hide();
            } else {
                this.showMaterials(option);
            }
        }
    },
    requestMaterials: function (option) {
        editRequest.getTagMaterials(option, {obj: leftComsZone, func: leftComsZone.showMaterials});
    },
    /**
     * 获取素材后，展示及处理公用数据
     * @param {type} option
     * @returns {undefined}
     */
    showMaterials: function (option) {
        if (option.data) {
            if (option.page === 1) {
                $("div.com-container").append(option.data);
            } else {
                option.comSection.append(option.data);
            }
        }
        if (option.comSection.length === 0) {
            option.comSection = $("#com-box-" + option.tag);
            var secId = "#com-box-" + option.tag;
            // niceScroll(secId,'fixed',156);
        }
        if (option.drake.containers.length > 1) {
            option.drake.containers.pop();
        }
        option.drake.containers.push(option.comSection[0]);
        option.comSection.show().siblings().hide();
        if (option.more && option.data === "") {
            this.tagInfo[option.tag].more = false;
        }
    },
    itemClick: function (option) {
        $el = $(option.el);
        //从收藏组件处点击item添加后去除右上角的删除标签
        $el.find('.left-shoucang-delete').remove();
        //点击预览区的素材块
        if ($el.attr('id') !== undefined) {
            gPreviewItemOnclick.wrap = option.el;
            gPreviewItemOnclick.el = option.event.target;
            rightEditZone.showEditor({el: option.el});
            //聚焦
            $("#" + gViewDetailBoxId).find(".item-border").removeClass('item-border');
            if ($el.data("type") == 10) {
                $(gPreviewItemOnclick.el).closest("div.com-content").addClass('item-border');
            } else {
                $el.addClass('item-border');
            }
            //边上工具栏
            var $siblings = $el.siblings();
            var $shoucang = $el.find('.com-item-option');
            if ($shoucang.length > 0) {
                $shoucang.show();
            } else {
                showShouCang($shoucang, $el);
            }
            $siblings.find('.com-item-option').remove();
        } else {
            //左侧素材块
            var $targetEl = $el.clone();
            if ($el.closest("section").attr("id") === "com-left-gallery-section") {
                this.adjustImgFromMyImage($targetEl);
            }
            $('#' + gViewDetailBoxId).append($targetEl);
            this.addHtmlId($targetEl);
//            rightEditZone.showEditor({el: $targetEl[0]});
            hideInitIntroduce();
            //滚动到底部
            $(window).scrollTop('9999');
        }
    },
    //调整从左侧我的图库 拖拽或点击加入到预览区的单图处理
    adjustImgFromMyImage:function($el) {
        $el.find(".com-delete-myimg").remove();
        $el.removeClass().addClass("com-item com-img com-img-1").attr("data-type", 2).attr("data-layout", 0).removeAttr("data-id").removeAttr("data-key");
    },
    addHtmlId: function ($targetEl) {
        var _id = 'hdj_' + Date.now().toString() + '_' + Math.ceil(Math.random() * 10000);
        $($targetEl).attr('id', _id);
        return _id;
    },
    getUserImages: function (option) {
        //option:page
        option = option || {};
        var $comLeftGallery = $("#com-left-gallery-section");
        if ($comLeftGallery.children("div").length === 0) {
            option.page = this.imagesInfo.page = 1;
            this.requestImages(option);
        } else {
            //get next page and show more
            if (option.more === true) {
                option.page = this.imagesInfo.page + 1;
                this.imagesInfo.page = option.page;
                this.requestImages(option);
            } else {
                option.more = false;
//                this.showUserImages(option);
            }
        }
    },
    requestImages: function (option) {
        option.more = true;
        editRequest.userImageList(option, {obj: leftComsZone, func: leftComsZone.showUserImages});
    },
    showUserImages: function (option) {
        var $myImageSection = $("#com-left-gallery-section");
        if (option.more === false) {
            $(".com-my-images").show().siblings("section").hide();
        } else {
            $myImageSection.append(option.data);
        }
        option.drake.containers.push($myImageSection[0]);
        if (option.more && (option.data === "" || option.data === undefined)) {
            this.imagesInfo.hasMore = false;
        }
    },
    delImage: function (option) {
//        layer.msg("开发阶段不允许删除");
//        return false;
        stopevt();
        layer.confirm("确定要删除吗",
                {
                    btn: ['确定', '取消'],
                    skin:'lay-delete',
                    title:false,
                    closeBtn:false
                },
                function (index) {
                    var $li = $(option.el).parents('.com-gallery');
                    var _id = $li.data("id");
                    $li.addClass('zoomOutDown');
                    editRequest.delUserImage({id: $li.data("id"), key: $li.data("key")});
                    setTimeout(function () {
                        $li.remove();
                    }, 300);
                    $("#lay-myimg-ul").find("li[data-id='" + _id + "']").remove();
                    layer.close(index);
                }, function () {
                    return true;
                }
        );
    },
    getUserMaterials: function (option) {
        //option:page
        option = option || {};
        var $myMaterialSection = $("section.com-my-material");
        if ($myMaterialSection.children().length === 0) {
            this.userMaterialsInfo.page = option.page = 1;
            this.requestUserMaterials(option);
        } else {
            //get next page and show more
            if (option.more === true) {
                option.page = this.userMaterialsInfo.page + 1;
                this.userMaterialsInfo.page = option.page;
                this.requestUserMaterials(option);
            } else {
                this.showUserMaterials(option);
            }
        }
    },
    requestUserMaterials: function (option) {
        option.more = true;
        editRequest.userMaterialList(option, {obj: leftComsZone, func: leftComsZone.showUserMaterials});
    },
    showUserMaterials: function (option) {
        var $comMyMaterialSection = $("section.com-my-material");
        if (option.more === false) {
            $comMyMaterialSection.show().siblings("section").hide();
        } else {
            for (var i in option.data) {
                var $oneHtml = $(option.data[i]['content']);
                $oneHtml.data("my-id", option.data[i]['id']);
                $comMyMaterialSection.append($oneHtml);
            }
        }
//        if (option.drake.containers.length > 1) {
//            option.drake.containers.pop();
//        }
        option.drake.containers.push($comMyMaterialSection[0]);
        if (option.more && (option.data === "" || option.data === undefined)) {
            this.userMaterialsInfo.hasMore = false;
        }
    },
    delUserMaterial: function (option) {
//        layer.msg("开发阶段不允许删除");
//        return false;
        var $item = $(option.el).parent('.com-item');
        $item.addClass('animated zoomOutDown');
        editRequest.delUserMaterial({id: $item.data("my-id")});
        setTimeout(function () {
            $item.remove();
        }, 1000);
    }
};

//右侧编辑区对象
var rightEditZone = {
    currentPreviewEl: null, //当前预览元素块
    currentCom: null, //当前编辑基础组件对象
    setting:{
        img:{rotate:0}
    },
    //渲染不同类型的编辑块
    showEditor: function (option) {
        var type = $(option.el).data('type');
        var com = COMS.factory(type);
        com.showEditor(option);
        var editId = com.getEditId();
        this.currentPreviewEl = option.el;
        this.currentCom = com;
        this.dragEditBox(editId);
    },
    //渲染快速插入文本的编辑区
    showFastInsertEditor:function(){
        var _id = 'hdj_' + Date.now().toString() + '_' + Math.ceil(Math.random() * 10000);
        var _type = 6,_layout = 0;
        var com = COMS.factory(0);
        com.showEditor({id:_id,type:_type,layout:_layout});
        var _editId = com.getEditId();
        this.currentPreviewEl = null;
        this.currentCom = com;
        //关掉了右侧编辑模块的拖拽效果 20171102
        //涉及 com.js  $editSection.css('top',_top);
        this.dragEditBox(_editId);
    },    
    //编辑后同步更新到预览区
    previewRender: function (option) {
        var _app = option.app || "www";
        var $parentSection = $(option.el).closest("section");
        var more = $parentSection.data("more");
        if (this.currentCom === null) {
            this.currentCom = COMS.factory(more.type);
        }
        //支持快速插入，再保存于预览区生成组件素材
        if(this.currentPreviewEl === null && more.id != '' && more.id != undefined){
            var _currentPreviewEl = '<div data-type="'+more.type+'" data-layout="'+more.layout+'" class="com-item com-txt" style="" id="'+more.id+'">'+
                                   '<div class="com-content" style=""></div>'+
                                    '</div>';
            $("#view-detail-box").append(_currentPreviewEl);
            this.currentPreviewEl = $("#"+more.id)[0];
            hideInitIntroduce(); 
        }
        this.currentCom.reloadPreview({app:_app,preview: this.currentPreviewEl, edit: $parentSection[0], type: more.type, layout: more.layout, id: more.id,setting:this.setting});
        this.setting.img.rotate = 0;
//        if (option.type === 0) {
//            //布局边框属性样式 @todo 如何支持内部dom结构的样式属性更新
//            var selectColor = option.el.style.backgroundColor;
//            var styleName = $(option.el).parent("div").data("name");
//            //        $("#"+thisId).css({"border-width":"2px","border-style":"double"});
//            $("#" + thisId).css(styleName, selectColor);
//        } else if (option.type === 6) {
//            //文本内容更新
//            $("#" + thisId).html(option.content);
//        }
    },
    //取消 关闭 编辑
    hideEditor: function (option) {
        if (option.el !== undefined) {
            $(option.el).closest("section").hide();
        }
    },
    //取消还原编辑
    restoreEditor: function (option) {
        var $previewEl = null;
        if (option.el !== undefined) {
            var $parentSection = $(option.el).closest("section");
            var more = $parentSection.data("more");
            $previewEl = $("#" + more.id);
        } else if (option.editorEl !== undefined) {
            $previewEl = $(option.editorEl);
        }
        if ($previewEl !== null) {
            this.showEditor({el: $previewEl[0], cancel: true});
        }
    },
    changeImage: function (option) {
        var $editImg = $(option.el).find("img");
        $editImg.attr("src", option.url);
        $editImg.css("max-height",this.calculateImgEditorMaxHeight($editImg));
    },
    calculateImgEditorMaxHeight:function ($img){
        var _imgHeight = $img[0].height;
        var _imgWidth = $img[0].width;
//        var _bodyClientHeight = document.body.clientHeight;
        var _screenHeight = window.screen.height;
        var _editImgMaxHeight = "100%";
        if(_imgHeight > _imgWidth){
            _editImgMaxHeight = _screenHeight*0.4;
        }      
        return _editImgMaxHeight;
    },    
    //新增图片
    addNewImages: function (option) {
        //{el:el,urls:{}}
        var $parentSection = $(option.el).closest("section");
        var more = $parentSection.data("more");
        if (this.currentCom === null) {
            this.currentCom = COMS.factory(more.type);
        }
        this.currentCom.addNewImages({preview: this.currentPreviewEl, edit: $parentSection[0], type: more.type, layout: more.layout, id: more.id, urls: option.urls});
    },
    //完成裁剪
    completeCropImage: function (option) {
        //{el:el,url:xxx}
        var $parentSection = $(option.el).closest("section");
        var more = $parentSection.data("more");
        if (this.currentCom === null) {
            this.currentCom = COMS.factory(more.type);
        }
        this.currentCom.changeCropImage({preview: this.currentPreviewEl, edit: $parentSection[0], type: more.type, layout: more.layout, id: more.id, url: option.url, el: option.el});
    },
    rotateImage:function(option){
        if(this.setting.img.rotate >= 360){
            this.setting.img.rotate = 90;
        }else{
            this.setting.img.rotate += 90;
        }
        var _rotate = "rotate("+this.setting.img.rotate+"deg)";
        var _css = {transform:_rotate};
        $(option.el).closest(".edit-img-box").find("img").css(_css);
    },
    /**
     * 删除右侧编辑区对应编辑块
     * @param {type} el 被移除的预览区组件
     * @returns {undefined}
     */
    removeEditor: function (option) {
        var _editor = $("#" + option.el.id + "-editor");
        if (_editor.length > 0) {
            _editor.remove();
        } else {
            $("#hdj-edit > section").hide();
        }
    },
    //可拖拽移动右侧编辑区
    dragEditBox:function (el) {
        $(el).udraggable({
            containment: '#edit_drag_container',
            handle: '.edit-title',
            start:function () {
                $('#edit_drag_container').addClass('udraggable_contaier');
            },
            stop:function () {
                // $('#edit_drag_container').removeClass('udraggable_contaier');
            }
        });
    }
};

var previewZone = {
    //收藏组件按钮
    collectComs: function (_this) {
        // $(_this).hide();
        var $comHtml = $(_this).parents('.com-item').clone().removeClass('item-border').removeAttr('id');
        var option = {name: ""};

        $comHtml.find('.com-item-option').remove();
        $('.com-my-material').prepend($comHtml);
        var $comMyMaterialTab = $("#com-my-material-tab");
        $comMyMaterialTab.find('span').addClass('com-box-title-clicked');
        $comMyMaterialTab.siblings().find('span').removeClass('com-box-title-clicked');
        $('#com-left>div:last').trigger('click');
        $("#left-shoucang").show().siblings().hide();

        option.type = $comHtml.data("type");
        if (!isNaN(option.type)) {
            option.from = 0;
        } else {
            option.from = 1;
        }
        option.content = $comHtml[0].outerHTML;
        editRequest.collectComs(option);
        layer.msg('收藏成功,在左侧【我的素材】查看', {
            time: 1500
        });
    },
    initContent: function (res) {
        if (res.code == -1) {
            layer.msg(res.msg);
            $("#currentEditId").val("");
            gEditId = 0;
            return false;
        }
        var data = res.data;
        //预览基本设置init
        $('#right_basic_banner').attr('data-value','mybanner');
        $("#center_basic_banner").attr("src", data.banner);
        $("#center_basic_title").text(data.title);
        $("#center_basic_organizer").text(data.organizer.name);
        var _priceText = "";
        if (data.fee_option > 1 && data.min_price == '收费') {
            _priceText = "收费";
        } else if(data.fee_option > 1){
            _priceText = data.min_price + "元"+((data.ticket_type_count==1)?"":"起");
        } else {
            _priceText = "免费";
        }
        $("#center_basic_price").text(_priceText);
        $("#center_basic_time").text(data.time_show);
        $("#center_basic_address").text(data.address);

        if (data.set_recommend == "1") {
            recommendToggle.initview('#basic_recommend', 'open');
        } else {
            recommendToggle.initview('#basic_recommend', 'close');
        }

        $("#right_basic_recommend").attr('data-value', data.set_recommend);

        //预览活动详情init
        if (data.content !== undefined) {
            $viewDetailBox = $("#" + gViewDetailBoxId);
            $viewDetailBox.html("");
            for (var i in data.content) {
                var $targetEl = $(data.content[i]);
                $viewDetailBox.append($targetEl);
                leftComsZone.addHtmlId($targetEl);
            }
        }

        //编辑区基本信息init
        $("#right_basic_banner").attr("src", data.banner);
        $("#right_basic_title").val(data.title);
        $("#right_basic_organizer").text(data.organizer.name).attr("data-id", data.organizer.id);
        $("#right_basic_organizer").prev("img").attr("src", data.organizer.icon);
        $("#right_basic_start_date").val(data.stime_date_show);
        $("#right_basic_end_date").val(data.etime_date_show);
        $("#right_basic_deadline_date").val(data.deadline_date_show);
        //$("#right_basic_end_time").val(data.etime_time_show);
        if(data.deadline_date_switch == 1){
            deadlineToggle.initview('#basic-time-toggle','open');
        }else{
            deadlineToggle.initview('#basic-time-toggle','close');
            $('#stop-time-input').show();
        }
        $("#right_basic_activity_type").val(data.online);
        activityType();
        if (data.online == 0) {
            $("#right_basic_prov").val(data.province);
            cityList.getCity();
            $("#right_basic_city").val(data.city);
            cityList.getArea();
            $("#right_basic_dist").val(data.area);
            $("#detailAddr").val(data.street);
            $("#addr-lng").val(data.lng);
            $("#addr-lat").val(data.lat);
            $('#basic-amap-input').show();
        }

        //编辑区报名设置init
        $(".join-way[data-value='" + data.sign_type + "']").trigger("click");
        if (data.sign_type == 0) {
            //票券列表
            ticketCOMS.tickets = [];
            $("#ticket_list").html("");
            for (var i in data.ticket) {
                var ticketItem = {
                    id:data.ticket[i].id,
                    name: data.ticket[i].name,
                    describe: data.ticket[i].describe,
                    isFree: data.ticket[i].is_free,
                    price: parseFloat(data.ticket[i].price),
                    tNum: parseInt(data.ticket[i].total_count),
                    lNum: parseInt(data.ticket[i].limit_count),
                    needCheck: data.ticket[i].is_audit
                };
                ticketCOMS.addTicket(ticketItem, true);
            }
            //报名表单项
            for (var formname in data.signKeys) {
                var _formInfo = data.signKeys[formname];
//                if (formname == '_name' || formname == '_phone') {
//                    continue;
//                }
                if(formname.indexOf("custom") > 0){
                    var optionHtml =
                        "<section class='input-box input-box2' data-type='" + formname +"'>" +
                        "<div class='i-type'>" +
                        "<span data-type='" + _formInfo.need + "' class='fa " + (_formInfo.need == 1 ? "fa-check-circle":"fa-circle-thin") + " f66926 fa-lg' onclick='optionSelected(this)'></span>" +
                        "<span>必填</span>" +
                        "</div>" +
                        "<div class='i-name i-name2'>" +
                        "<input class='i-name-input' type='text' placeholder='选项名称' value='" + _formInfo.label + "'>" +
                        "</div>" +
                        "<div class='i-msg i-msg2'>" +
                        "<input class='i-msg-input' type='text' placeholder='请填写提示信息' value='" + _formInfo.tip + "'>" +
                        "</div>" +
                        "<div class='i-other'>" +
                        "<span class='fa fa-trash-o fa-lg f66926 pointer' onclick='deleteOption(this)'></span>" +
                        "</div>" +
                        "</section>";
                    $('.bacic-option-box').append(optionHtml);
                }else{
                    $(".basic-colla-li[data-type='" + formname + "']").trigger("click");

                    var $formSection = $(".bacic-option-box").find("section[data-type='" + formname + "']");
                    if (_formInfo.need == 0) {
                        $formSection.find('.i-type>span').first().attr("data-type", 0).removeClass().addClass("fa f66926 fa-lg fa-circle-thin");
                    }else{
                        $formSection.find('.i-type>span').first().attr("data-type", 1).removeClass().addClass("fa fa-check-circle f66926 fa-lg");
                    }
                    if (_formInfo.tip != "") {
                        $formSection.find('.i-msg-input').val(_formInfo.tip);
                    }
                }
            }
        } else if (data.sign_type == 1) {
            var $withoutFeeOption  = $("#without_fee_option");
            $withoutFeeOption.attr("data-value",data.fee_option);
            if (data.fee_option < 2) {
                $withoutFeeOption.find(".tab-other-free-btn").addClass("orange").siblings().removeClass("orange");
            } else {
                $withoutFeeOption.find(".tab-other-charge-btn").addClass("orange").siblings().removeClass("orange");
            }
        } else if (data.sign_type == 2) {
            var $otherFeeOption  = $("#other_fee_option");
            $otherFeeOption.attr("data-value",data.fee_option);
            if (data.fee_option < 2) {
                $otherFeeOption.find(".tab-other-free-btn").addClass("orange").siblings().removeClass("orange");
            } else {
                $otherFeeOption.find(".tab-other-charge-btn").addClass("orange").siblings().removeClass("orange");
            }
            $("#other_content").val(data.notice.content);
            for (var i in data.notice.infos) {
                addContact(data.notice.infos[i]['k'],data.notice.infos[i]['l'],data.notice.infos[i]['v']);
                var $infoItem = $(".tab-contact-btn[data-id='" + data.notice.infos[i]['k'] + "']");
                $infoItem.addClass('orange');
                $infoItem.attr('data-type','1');
//                $(".tab-contact-btn[data-id='" + data.notice.infos[i]['k'] + "']").trigger("click");
//                $(".tab-join-section[data-id='" + data.notice.infos[i]['k'] + "']").find("input").val(data.notice.infos[i]['v']);
            }
        }
        
        //标签数据
        var _tagsIdString = '';
        if(data.tags != null && data.tags.length > 0){
            $('.view-tags-box').html('');
            for(var i in data.tags){
                $('.view-tags-box').append('<span class="view-tag-item">' + data['tags'][i]['name'] + '</span>');
                _tagsIdString += data['tags'][i]['id'] + ",";
                $('#selected_tags_list').prepend(
                    "<div>" +
                    "<div class='tag-item-name'><span class='tag-delete pointer' onclick='tags.deleteTag(this)'>× </span><span class='tag-text' data-value='" + data['tags'][i]['id'] + "'>" + data['tags'][i]['name'] + "</span></div> " +
                    "<div class='tag-type-box' id='tag_category_div_" + data['tags'][i]['id'] + "'>" +
                    "<select id='category_select_" + data['tags'][i]['id'] + "' class='tag-type-select' onchange='tags.addTagsType(this)' tag_id='" + data['tags'][i]['id'] + "'>" +
                    "<option value='0'>请选择..</option>"+
                    "</select>" +
                    "</div>" +
                    "</div>"
                );
                var options = '';
                var _clist = data['category_list'];
                for (var key in _clist) {
                    options += '<option value="' + _clist[key]['id'] + '">' + _clist[key]['name'] + '</option>';
                }
                $(options).appendTo("select#category_select_" + data['tags'][i]['id']);

                var _tagClist = data['tags'][i]['clist'];
                for (var key2 in _tagClist) {
                    var tag_category =
                        "<div class='tag-type-item'>" +
                        "<span class='tag-type-text'>" + _tagClist[key2]['name'] + "</span>" +
                        "<span class='tag-type-delete' style='display:none;' onclick='tags.removeTagsType(this)' tag_id='" + data['tags'][i]['id'] + "' categroy_id='" + _tagClist[key2]['category_id'] + "'>" + "去除该分类" + "</span>" +
                        "</div>";
                    $("#tag_category_div_" + data['tags'][i]['id']).append(tag_category);
                }
            }
            _tagsIdString = _tagsIdString.substring(0, _tagsIdString.length - 1);
            $("#selected_tags_data").val(_tagsIdString);
            $('#tag_name').val('');
            $('.tag-type-item').on('mouseover', function () {
                $(this).find('.tag-type-text').css('display', 'none');
                $(this).find('.tag-type-delete').css('display', 'block');
            });
            $('.tag-type-item').on('mouseleave', function () {
                $(this).find('.tag-type-text').css('display', 'block');
                $(this).find('.tag-type-delete').css('display', 'none');
            });
        }

        var _basicInitData = {
            id: data.id,
            poster: data.banner,
            title: data.title,
            sponsorId: data.organizer.id,
            sTime: data.stime,
            eTime: data.etime,
            signType: data.sign_type,
            signKeys: data.signKeys,
            signTickets: ticketCOMS.tickets,
            feeOption: data.fee_option,
            signOther: data.notice,
            online: data.online,
            lng: data.lng,
            lat: data.lat,
            province: data.province,
            city: data.city,
            area: data.area,
            street: data.street,
            recommend: data.set_recommend
        };
        basicCOMS.editInit(_basicInitData);
    },
    //视频双击弹窗播放
    playVideo:function (_this) {
        var videoSrc = $(_this).data('content');
        if(videoSrc == undefined){
            layer.msg('请添加正确的视频地址再进行预览')
        }else {
            layer.open({
                type: 1,
                skin:'lay-video-hdj',
                title: '视频预览',
                shadeClose: true,
                shade: 0.8,
                area: ['500px', '500px'],
                content: videoSrc,
                closeBtn:2
            });
        }
    }


};

//top
var topZone = {
    fastComs: {}, //快捷组件html对象
    initFastComs: function (data) {
        topZone.fastComs = data;
    },
    requestFastComs: function () {
        editRequest.getFastComs({}, {func: topZone.initFastComs, obj: topZone});
    },
    toAddCom: function (el) {
        var _type = $(el).data("type");
        if (_type === 2) {
            myGallery.open({from: el,multiple:true, change: false, layer: "#lay-myimg-box", callback: {obj: topZone, func: topZone.toShowPreview, params: {type: _type}}});
        } else if (_type === 8) {
            myVideo.open({from: el, callback: {obj: topZone, func: topZone.toShowPreview, params: {type: _type}}});
        } else {
            if (_type == 1) {
                //只支持一个富文本
                var $htmlComs = $("#view-detail-box").children("div[data-type='1']");
                if ($htmlComs.length > 0) {
                    $htmlComs.trigger("click");
                    return false;
                }
            }
            this.toShowPreview({type: _type});
        }
    },
    toShowPreview: function (option) {
        var $targetEl = $(this.fastComs[option.type]['html']);
        if (option.type === 2) {
            for(i in option.urls){
                $targetEl = $(this.fastComs[option.type]['html']);
                $targetEl.find("img").attr("src", option.urls[i]);
                leftComsZone.addHtmlId($targetEl);
                $('#' + gViewDetailBoxId).append($targetEl);                
            }
        } else {
            if (option.type === 8) {
                $targetEl.data("content", option.text);
                $targetEl.data("input", option.input);
                $targetEl.find(".com-play-icon").attr("src", "http://img.huodongju.com/www/component/com-video2.png");
                $targetEl.find('.play-video-text').text("双击可预览视频");
            }
            leftComsZone.addHtmlId($targetEl);
            $('#' + gViewDetailBoxId).append($targetEl);
        }
//        rightEditZone.showEditor({el: $targetEl[$targetEl.length - 1]});
        hideInitIntroduce();
        $(window).scrollTop('9999');
    }

};
